Integer type or not [closed]
Posted
by
kira
on Programmers
See other posts from Programmers
or by kira
Published on 2012-06-03T01:59:11Z
Indexed on
2012/06/03
4:47 UTC
Read the original article
Hit count: 192
c++
I am writing a program (in cpp) to check the primality of a given number
The point where i am struck is , I need to check in between the program wether the value i obtained upon some arithmetic operations on the input is an integer or not
i.e lets say input is 'a'
I want to know how to check if 'b' is integer or not (FYI, b=(a+1)/6 )
My attempt for this :
int main()
{
using std::cin;
using std::cout;
int b,c;
int a;
cout<<"enter the number";
cin>>a;
b=(a+1)/6;
c=(a-1)/6;
if (b is an integer)
cout << "The given number is prime";
else if (c is an integer)
cin << "The given number is prime!";
else
cout<<"The number is not prime";
return 0;
}
© Programmers or respective owner